﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;

namespace redesII
    {
    public partial class Form1 : Form
        {

        //private ObjectQuery objQuery = new ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3");
        private ObjectQuery objQuerys = new ObjectQuery("Select * from Win32_LogicalDisk");
        private ManagementObjectSearcher searcher = null;
        private string query;


        public Form1()
            {
            InitializeComponent();
            }

        private void btnRun_Click(object sender, EventArgs e)
            {

            if (cmbBusca.SelectedIndex < 0)
                {
                MessageBox.Show("Deve-se selecionar um tipo de busca",
                    "Redes II", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
                }

            TipoQuery tipoQuery = new TipoQuery();
            switch (cmbBusca.SelectedIndex)
                {
                case 0:
                    tipoQuery = TipoQuery.process;
                    break;
                case 1:
                    tipoQuery = TipoQuery.hard_drive;
                    break;
                case 2:
                    tipoQuery = TipoQuery.ram_memory;
                    break;
                default:
                    break;
                }
            WMIProperties oProperties = new WMIProperties(tipoQuery);

            if (!chkTarget.Checked)
                {
                User user = new User(txtLogin.Text.Trim(), txtPWD.Text.Trim(), txtEstacao.Text.Trim());
                oProperties.BuscarDados(tipoQuery, user);
                }
            else { oProperties.BuscarDados(tipoQuery); }

            List<WMIField> properties = oProperties.Properties;

            }
        }
    }